using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Shrapnel.Interaction
{
	/// <summary>
	/// An interaction style resembling the default interaction style of Maya.
	/// </summary>
	class StyleMaya : Style 
	{
		//
		// Latent actions:
		//

		public override bool ShouldStartPanning(MouseButtons mouseButtons, Keys modifierKeys, AboveElementType above)
		{
			return (mouseButtons == MouseButtons.Middle &&
				((modifierKeys & Keys.Alt) == Keys.Alt));
		}

		public override bool ShouldStopPanning(MouseButtons mouseButtons, Keys modifierKeys)
		{
			return !ShouldStartPanning(mouseButtons, modifierKeys, AboveElementType.None);
		}

		public override bool ShouldStartSelecting(MouseButtons mouseButtons, Keys modifierKeys, AboveElementType above)
		{
			return mouseButtons == MouseButtons.Left &&
				((modifierKeys & Keys.Alt) == 0) &&
				(above == AboveElementType.None || above == AboveElementType.Cable);
		}

		public override bool ShouldStopSelecting(MouseButtons mouseButtons, Keys modifierKeys)
		{
			return !ShouldStartSelecting(mouseButtons, modifierKeys, AboveElementType.None);
		}

		public override bool ShouldStartZooming(MouseButtons mouseButtons, Keys modifierKeys, AboveElementType above)
		{
			return (mouseButtons == MouseButtons.Right &&
				((modifierKeys & Keys.Alt) == Keys.Alt));
		}

		public override bool ShouldStopZooming(MouseButtons mouseButtons, Keys modifierKeys)
		{
			return !ShouldStartZooming(mouseButtons, modifierKeys, AboveElementType.None);
		}


		public override bool ShouldStartMoving(MouseButtons mouseButtons, Keys modifierKeys, AboveElementType above)
		{
			return mouseButtons == MouseButtons.Left &&
				((modifierKeys & Keys.Alt) == 0) &&
				(above == AboveElementType.Node);
		}

		public override bool ShouldStopMoving(MouseButtons mouseButtons, Keys modifierKeys)
		{
			return !ShouldStartMoving(mouseButtons, modifierKeys, AboveElementType.Node);
		}

		public override bool ShouldStartWiring(MouseButtons mouseButtons, Keys modifierKeys, AboveElementType above)
		{
			return mouseButtons == MouseButtons.Left &&
				((modifierKeys & Keys.Alt) == 0) &&
				(above == AboveElementType.Connector);
		}

		public override bool ShouldStopWiring(MouseButtons mouseButtons, Keys modifierKeys)
		{
			return !ShouldStartWiring(mouseButtons, modifierKeys, AboveElementType.Connector);
		}

		//
		// Instant actions:
		//

		public override bool ShouldDoFitSelectionInView(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.F) && ((modifierKeys & Keys.Control) == 0);
		}

		public override bool ShouldDoFitAllInView(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.F) && ((modifierKeys & Keys.Control) == Keys.Control);
		}

		public override bool ShouldDoDeleteSelection(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.Delete);
		}

		// CTRL-A
		public override bool ShouldDoSelectAll(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.A) && ((modifierKeys & Keys.Control) == Keys.Control) &&
				((modifierKeys & Keys.Shift) == 0);
		}

		// CTRL-SHIFT-A
		public override bool ShouldDoDeselectAll(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.A) && ((modifierKeys & Keys.Control) == Keys.Control) &&
				((modifierKeys & Keys.Shift) == Keys.Shift);
		}

		// CTRL-C
		public override bool ShouldDoCopySelection(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.C) && ((modifierKeys & Keys.Control) == Keys.Control);
		}

		// CTRL-X
		public override bool ShouldDoCutSelection(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.X) && ((modifierKeys & Keys.Control) == Keys.Control);
		}

		// CTRL-V
		public override bool ShouldDoPaste(KeyEventArgs keyArgs, Keys modifierKeys)
		{
			return (keyArgs.KeyCode == Keys.V) && ((modifierKeys & Keys.Control) == Keys.Control);
        }

        // CTRL+P
        public override bool ShouldPrint(KeyEventArgs keyArgs, Keys modifierKeys)
        {
            return (keyArgs.KeyCode == Keys.P) && ((modifierKeys & Keys.Control) == Keys.Control);
        }
	}
}
